/****************************************************
	文件：UseCurativePotionBev.cs
	作者：HuskyT
	邮箱：1005240602@qq.com
	日期：2020/5/31 16:39:41
	功能：使用治疗药剂的行为
*****************************************************/

using UnityEngine;

namespace AIModule.Utility.Example
{
    public class UseCurativePotionBev : IReceiver
    {
        public void Execute(BlackboardItem bb)
        {
            if (bb.SelfModel.CurativePotionNum.Value < 1)
            {
                Debug.LogWarningFormat("{0} 已经没有治疗药剂了！", bb.SelfModel.Name);
                return;
            }
            int minCurative = Consts.CURATIVE_POTION_POTENCY - Consts.CURATIVE_POTION_POTENCY_RANGE_RADIUS;
            int maxCurative = Consts.CURATIVE_POTION_POTENCY + Consts.CURATIVE_POTION_POTENCY_RANGE_RADIUS;
            int curative = MathUtil.GetRandom(minCurative, maxCurative, GameRoot.Instance.Random);
            bb.SelfModel.CurativePotionNum.Value -= 1;
            bb.SelfModel.Hp.Value += curative;
            Debug.LogWarningFormat("{0} 使用了治疗药剂，恢复生命值 {1}", bb.SelfModel.Name, curative);
        }
    }
}